package com.upb.webserver.user;

import com.upb.webserver.common.enums.ChainTypeEnum;
import com.upb.webserver.common.exception.WebServerException;
import com.upb.webserver.common.returncode.ConstantCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFactory {
    @Autowired
    private FiscoUserService fiscoUserService;


    public BaseUserService getUserServiceByChainType(byte chainType) {
        return getUserServiceByChainType(ChainTypeEnum.getById(chainType));
    }


    public BaseUserService getUserServiceByChainType(ChainTypeEnum chainTypeEnum) {
        switch (chainTypeEnum) {
            case FISCO:
                return fiscoUserService;
        }
        throw new WebServerException(ConstantCode.CHAIN_TYPE_NOT_SUPPORT);
    }
}
